package com.daykw.douyin.utils;

import java.util.concurrent.atomic.AtomicInteger;

public class RadomU {
	private RadomU() {
	}

	private static RadomU single = null;

	private static AtomicInteger atomicInteger = new AtomicInteger(0);

	public static RadomU getInstance() {
		if (single == null) {
			single = new RadomU();
		}
		return single;

	}

	public synchronized Integer getValue() {
		Integer i = atomicInteger.getAndIncrement();
		return i;
	}

	public static void main(String[] args) {

		int i1 = RadomU.getInstance().getValue();
		System.out.println(i1);
		new Thread() {
			public void run() {
				for (int j = 0; j < 1000; j++) {
					int i2 = RadomU.getInstance().getValue();
					int ss = i2%6;
					System.out.println(ss);
				}
			}
		}.start();
		new Thread() {
			public void run() {
				for (int j = 0; j < 1000; j++) {
					int i2 = RadomU.getInstance().getValue();
					System.out.println(i2);
				}
			}
		}.start();
	}
}
